﻿
<UserControl x:Class="MDSAdministration.ColumnCodeCheck"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:MDSAdministration="clr-namespace:MDSAdministration"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Style x:Key="defaultColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid>
                            <CheckBox  x:Name="HeaderCheckBox" IsChecked="True" Content="{Binding}" Checked="Header_CheckBox_Checked" Unchecked="Header_CheckBox_Unchecked" Margin="3,6,0,0" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        </Style>
    </UserControl.Resources>
    <Grid Background="AliceBlue">
        <Grid.RowDefinitions>
            <RowDefinition Height="26" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Height="26" VerticalAlignment="Top" HorizontalAlignment="Stretch">
            <Border BorderThickness="1" BorderBrush="#FF8E8F8F">
                <Grid>
                    <CheckBox Height="16" HorizontalAlignment="Left" Margin="5,6,0,0" Name="checkBox" VerticalAlignment="Top" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" />
                    <Label Content="All Columns" Margin="24,0,0,0"  />
                </Grid>
            </Border>
        </Grid>
        <Grid VerticalAlignment="Stretch"  Margin="0,26,0,0" Grid.RowSpan="2" HorizontalAlignment="Stretch">
            <DataGrid HeadersVisibility="Column" AutoGenerateColumns="False"  HorizontalAlignment="Stretch"  Name="dgCode" VerticalAlignment="Stretch"  CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" ScrollViewer.VerticalScrollBarVisibility="Hidden" >
                <DataGrid.Resources>
                    <Style TargetType="ScrollViewer">
                        <Setter Property="MDSAdministration:ScrollSynchronizer.ScrollGroup" Value="Group1" />
                    </Style>
                </DataGrid.Resources>
                <DataGrid.Columns>
                    <DataGridTemplateColumn x:Name="IsChecked" IsReadOnly="False" Visibility="Visible" HeaderStyle="{StaticResource defaultColumnHeaderStyle}">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox IsChecked="{Binding Path=IsChecked, UpdateSourceTrigger=PropertyChanged}" x:Name="cbxCellTemplateAttribute" Margin="2,1,0,0" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="Code" Binding="{Binding Code}" Width="*" x:Name="dgtcCode" IsReadOnly="True"/>
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
    </Grid>
</UserControl>
